package doudou.pojo;

import doudou.Interface.NetService;
import doudou.Interface.SendService;
import doudou.Interface.TalkService;

import java.io.Serializable;

//超人套餐
public class SuperPackage  extends ServicePackage implements SendService, TalkService, NetService , Serializable {
    public SuperPackage() {
        super("超人套餐",78, 200, 1024, 50);
    }

    public void showInfo() {
        super.showInfo();
    }

    public int netPlay(int minCount, MobileCard card) {
        return 0;
    }

    public int send(int minCount, MobileCard card) {
        int text = card.getRealSMSCount();
        int useText;
        double spend;

        if (text >= minCount) {
            useText = minCount;
            card.setRealSMSCount(text - minCount);
        } else {
            int overSms = minCount - text;
            spend = overSms * 0.1;
            double restMoney = card.getMoney() - spend;

            if (restMoney > 0) {
                useText = minCount;
                card.setRealSMSCount(0);
                card.setMoney(restMoney);
                card.setConsumAmount(card.getConsumAmount() + spend);
            } else {
                int extraSms = (int) (card.getMoney() / 0.1);
                useText = text + extraSms;
                card.setRealSMSCount(0);
                card.setMoney(0);
                card.setConsumAmount(card.getConsumAmount() + (extraSms*0.1));
                try {
                    throw new Exception("您已发送" + useText + "条短信，您的余额不足，请充值后使用!");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return useText;
    }

    public int call(int minCount, MobileCard card) {
        return 0;
    }
}
